﻿@model Bibilioteca.Models.Material

@{
    ViewBag.Title = "Edit";
}

<h2>Edit</h2>
@if (Model.Id != 0)
{
    using (Html.BeginForm()) 
    {
        @Html.ValidationSummary(true)

        <fieldset>
            <legend>Material</legend>

            @Html.HiddenFor(model => model.Id)

            <div class="editor-label">
                @Html.LabelFor(model => model.Codigo)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.Codigo)
                @Html.ValidationMessageFor(model => model.Codigo)
            </div>

            <div class="editor-label">
                @Html.LabelFor(model => model.Titulo)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.Titulo)
                @Html.ValidationMessageFor(model => model.Titulo)
            </div>

            
            <div class="editor-label">
                Autor(es)
            </div>
            <div class="editor-field">
                @Html.ListBoxFor(model => model.Autores, ViewBag.Autores as MultiSelectList)
                @Html.ValidationMessageFor(model => model.Autores)
            </div>

            
            <div class="editor-label">
                @Html.LabelFor(model => model.Sinopsis)
            </div>
            <div class="editor-field">
                @Html.EditorFor(model => model.Sinopsis)
                @Html.ValidationMessageFor(model => model.Sinopsis)
            </div>

            <div class="editor-label">
                Tipo de Material
            </div>
            <div class="editor-field">
                @Html.DropDownListFor(x => x.SelectedTipoMaterial, new SelectList(ViewBag.TiposMateriales, "Value", "Text", Model.SelectedTipoMaterial.ToString()))
                <!-- @Html.EditorFor(model => model.SelectedTipoMaterial) -->
                @Html.ValidationMessageFor(model => model.SelectedTipoMaterial)
            </div>

            <div class="editor-label">
                Editorial
            </div>
            <div class="editor-field">
                @Html.DropDownListFor(x => x.SelectedEditorial, new SelectList(ViewBag.Editoriales, "Value", "Text", Model.SelectedEditorial.ToString()))
                <!-- @Html.EditorFor(model => model.SelectedEditorial) -->
                @Html.ValidationMessageFor(model => model.SelectedEditorial)
            </div>

            <div class="editor-label">
                Catalogo
            </div>
            <div class="editor-field">
                @Html.DropDownListFor(x => x.SelectedCatalogo, new SelectList(ViewBag.Catalogos, "Value", "Text", Model.SelectedCatalogo.ToString()))
                <!-- @Html.EditorFor(model => model.SelectedCatalogo) -->
                @Html.ValidationMessageFor(model => model.SelectedCatalogo)
            </div>

            <p>
                <input type="submit" value="Save" />
            </p>
        </fieldset>
    }
}
else
{ 
     <p>Este usuario no existe </p>
}
<div>
    @Html.ActionLink("Back to List", "Index")
</div>
    
@section Scripts {
    @Scripts.Render("~/bundles/jqueryval")
}
